def isPrime():
    for i in range(2,n):
        if n % i==0:
            return False
        return True
def getNumbers():
    t=[]
    for i in range(1,5):
        for j in range(1,5):
            for k in range(1,5):
                for m in range(1,5):
                    if i!=j and i!=k and i!=m and j!=m and k!=m:
                        t.append(1000*i+100*j+10*k+m)

    return t

def main():
    number=getNumbers()
    for n in number:
        if isPrime(n):
            print(n)

main()
